package com.wuge.springInjection0807.Event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * Created by Administrator on 2017/8/7.
 */
public class MessageListener implements ApplicationListener<ApplicationEvent> {

    // 监听器实现 ApplicationListener 接口，实现onApplicationEvent方法；
    public void onApplicationEvent(ApplicationEvent event){
        if(event instanceof MessageEvent){
            MessageEvent messageEvent = (MessageEvent) event;
            System.out.println("信息内容是:" + messageEvent.getMessageContent());
        }else{
            System.out.println("其他的信息！" + event.toString());
        }
    }
}
